// Achievement by G3X / GeXeH - Enjoy
// Version 1.0

// Achievement: Get rated 'love' 50 times.

local total = achievements.GetValue( "Loved By All", "total", 0 )

local oldRate
local function Update()
	local ply = LocalPlayer()
	if ( !ValidEntity( ply ) ) then return end
	if ( total == 50 ) then return end
	
	local love = ply:GetNWInt( "Rating.love", -1 )
	if ( love > ( oldRate or love ) ) then
		if ( oldRate != 0 || love == 1 ) then
			total = math.Clamp( total + ( love - oldRate ), 0, 50 )
			achievements.Update( "Loved By All", total / 50, total .. "/50" )
			achievements.SetValue( "Loved By All", "total", total )
		end
	end
	oldRate = love
end
timer.Create( "Achievements.LovedByAll", 1, 0, Update )

achievements.Register( "Loved By All", "Get rated 'love' 50 times.", "achievements/lovedbyall", total / 50, total .. "/50" )